package com.xiaohudie.JUC;

/**
 * @Author xiao hu die
 * @Date 2022/1/13 22:12
 * @Version 1.0
 */

import java.util.List;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;

/**使用CopyOnWriteArrayList
 * 写时复制技术*/
public class Thread0503 {
    public static void main(String[] args) {
        List<String> stringList =new CopyOnWriteArrayList<>();
        for (int i = 0; i < 20; i++) {
            new Thread(()->{
                stringList.add(UUID.randomUUID().toString().substring(0,7));
                System.out.println(stringList);
            },String.valueOf(i)).start();
        }
    }
}
